package kr.hkit.androidcomplete01.ch19;

import kr.hkit.androidcomplete01.R;
import android.app.ListActivity;
import android.content.Intent;
import android.os.Bundle;
import android.view.View;
import android.widget.ArrayAdapter;
import android.widget.ListView;
import android.widget.Toast;

public class Ch19Main extends ListActivity {
	private String[] subList;
	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		
/*		subList = getResources().getStringArray(R.array.ch12_list);
		
		ArrayAdapter<String> adapter = new ArrayAdapter<String>(this, android.R.layout.simple_list_item_1,subList);*/
		
		ArrayAdapter<CharSequence> adapter = ArrayAdapter.createFromResource(this, R.array.ch19_list, 
				android.R.layout.simple_list_item_1);
		setListAdapter(adapter);
	}
	
	@Override
	protected void onListItemClick(ListView l, View v, int position, long id) {
		super.onListItemClick(l, v, position, id);
		Toast.makeText(this, "position = " + position, Toast.LENGTH_LONG).show();
		Intent intent = null;
		switch(position){
		case 0:
			intent = new Intent(this, ThreadEx.class);
			break;
		case 1:
			intent = new Intent(this, HandlerEx.class);
			break;
		case 2:
			intent = new Intent(this, LongTime2.class);
			break;
		case 3:
			intent = new Intent(this, LongTime3.class);
			break;
		case 4:
			intent = new Intent(this, LongTime4.class);
			break;

		}
		startActivity(intent);
	}
}
